//
//  XBShoppingCell.m
//  xunbao
//
//  Created by 程顺晓 on 16/4/4.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "XBShoppingCell.h"
#import "XBShopping.h"
#import "UIView+SDAutoLayout.h"
#import "UIImageView+WebCache.h"
#import "XBList.h"

#define labelFont(a) [UIFont systemFontOfSize:a];

@interface XBShoppingCell ()
@property (weak, nonatomic) IBOutlet UIImageView *shoppingImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@end

@implementation XBShoppingCell

- (void)awakeFromNib {
    [self setupLabelFont];
}

- (void)setShopping:(XBShopping *)shopping{
    
    _shopping = shopping;

    self.titleLabel.text = shopping.title;
    self.priceLabel.text = [NSString stringWithFormat:@"￥%@",shopping.price];
    self.priceLabel.textColor = [UIColor orangeColor];
}
- (void)setList:(XBList *)list{
    _list = list;
    [self.shoppingImageView sd_setImageWithURL:[NSURL URLWithString:list.imgUrl]];
    
}
//适配
- (void)setupLabelFont{
    if ([UIScreen mainScreen].bounds.size.width==414) {
        self.titleLabel.font = labelFont(13)
        self.priceLabel.font = labelFont(13)
    }else if([UIScreen mainScreen].bounds.size.width==375){
        self.titleLabel.font = labelFont(11)
        self.priceLabel.font = labelFont(11)
    }else{
        self.titleLabel.font = labelFont(9)
        self.priceLabel.font = labelFont(9)
        self.titleLabel.sd_layout.topSpaceToView(self.shoppingImageView,0).heightIs(18);
    }
}
@end
